package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author Pan Rundong
 * @Date 2023-03-06 10:30
 * @Desc 地理功能Controller
 */
@RestController
@RequestMapping("baidu")
public class BaiduController {
    @Autowired
    private BaiduService baiduService;

    /**
     * 上报地理信息
     *
     * @param map
     * @return org.springframework.http.ResponseEntity
     * @Author Pan Rundong
     */
    @PostMapping("location")
    public ResponseEntity location(@RequestBody Map map) {
        Double latitude = Double.valueOf(map.get("latitude").toString()) ;
        Double longitude = Double.valueOf(map.get("longitude").toString()) ;
        String addr = map.get("addrStr").toString();
        baiduService.location(latitude, longitude, addr);
        return ResponseEntity.ok(null);
    }
}
